//
//  CTCoinListCell.m
//  digitalCurrency
//
//  Created by 默认账户 on 2019/6/1.
//  Copyright © 2019 XinHuoKeJi. All rights reserved.
//

#import "CTCoinListCell.h"

@interface CTCoinListCell ()



@end

@implementation CTCoinListCell

+ (instancetype)createTableView:(UITableView *)tableView {
    CTCoinListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"headlistcell"];
    cell.selectionStyle  = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor whiteColor];
    
    [cell makeViews];
    
    return cell;
}
    
- (void)makeViews {
    
    CGFloat width1_3 = (SCREEN_WIDTH-70)/3.0;

    [self.contentView addSubview:self.bgView];
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.top.mas_equalTo(5);
        make.height.mas_equalTo(60);
        make.width.mas_equalTo(SCREEN_WIDTH-24);
    }];
    
    [self.bgView addSubview:self.coinImgView];
    [self.coinImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(8);
        make.width.height.mas_equalTo(40);
    }];
    
    [self.bgView addSubview:self.coinName];
    [self.coinName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(70);
        make.top.mas_equalTo(14);
        make.height.mas_equalTo(12);
        make.width.mas_equalTo(width1_3);
    }];
    
    [self.bgView addSubview:self.coinChinaName];
    [self.coinChinaName mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(70);
        make.top.mas_equalTo(35);
        make.height.mas_equalTo(12);
        make.width.mas_equalTo(width1_3);
    }];
    
    [self.bgView addSubview:self.coinDollarPrice];
    [self.coinDollarPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(60 + width1_3);
        make.top.mas_equalTo(14);
        make.height.mas_equalTo(12);
        make.width.mas_equalTo(width1_3);
    }];
    
    [self.bgView addSubview:self.coinRMBPrice];
    [self.coinRMBPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(60 + width1_3);
        make.top.mas_equalTo(35);
        make.width.mas_equalTo(width1_3);
    }];
    
    [self.bgView addSubview:self.coinPercent];
    [self.coinPercent mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-8);
        make.top.mas_equalTo(15);
        make.height.mas_equalTo(30);
        make.width.mas_equalTo(68);
    }];
   
}
    
- (UIImageView *)coinImgView {
    if (!_coinImgView) {
        _coinImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"announce"]];
        _coinImgView.backgroundColor = [UIColor clearColor];
//        _coinImgView.layer.cornerRadius = 20;
//        _coinImgView.layer.masksToBounds = YES;
//        _coinImgView.hidden = YES;
    }
    return _coinImgView;
}
    
- (UILabel *)coinName {
    if (!_coinName) {
        UILabel *name = [[UILabel alloc] init];
        name.textColor = [UIColor colorWithHEX:@"#EEEEEE"];
        name.font = [UIFont systemFontOfSize:18];
//
//        NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"DWTT" attributes:@{NSFontAttributeName: [UIFont fontWithName:@"PingFangSC-Regular" size: 12],NSForegroundColorAttributeName: [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0]}];
//        name.attributedText = string;
        _coinName = name;
    }
    
    return _coinName;
}

- (UILabel *)coinChinaName {
    if (!_coinChinaName) {
        UILabel *label = [[UILabel alloc] init];
        label.textColor = [UIColor whiteColor];
        label.font = [UIFont systemFontOfSize:12];
//        label.hidden = YES;
        _coinChinaName = label;
    }
    
    return _coinChinaName;
}
    
- (UILabel *)coinDollarPrice {
    if (!_coinDollarPrice) {
        UILabel *label  = [[UILabel alloc] init];
        label.textColor = [UIColor whiteColor];
        label.font = [UIFont systemFontOfSize:18];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = @"$0.00";
        
        _coinDollarPrice = label;
    }
    
    return _coinDollarPrice;
}
    
- (UILabel *)coinRMBPrice {
    if (!_coinRMBPrice) {
        UILabel *label  = [[UILabel alloc] init];
        label.textColor = [UIColor whiteColor];
        label.font = [UIFont systemFontOfSize:12];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = @"￥0.00";
//        label.hidden = YES;
        _coinRMBPrice = label;
    }
    
    return _coinRMBPrice;
}
    
- (UIButton *)coinPercent {
    if (!_coinPercent) {
        UIButton *label = [UIButton buttonWithType:UIButtonTypeCustom];
        label.layer.masksToBounds = YES;
        label.layer.cornerRadius = 4;
        label.titleLabel.font = [UIFont systemFontOfSize:18];
        [label setTitle:@"--" forState:UIControlStateNormal];
        [label setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _coinPercent = label;
    }
    
    return _coinPercent;
}

- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc] init];
        _bgView.layer.cornerRadius = 5;
        _bgView.backgroundColor = [UIColor whiteColor];
    }
    
    return _bgView;
}
@end
